{
  "name": "Marcone Email Tracking Extractor - template",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {
          "q": "subject: Marcone Instant Shipping Notification",
          "sender": " no-replies@marcone.com"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        96,
        224
      ],
      "id": "bf95b2b9-8607-457d-9535-150b66790530",
      "name": "Gmail Trigger",
      "credentials": {
        "gmailOAuth2": {
          "id": "RaTsrmolHvJbOjlm",
          "name": "Gmail GVL"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You're an AI assistant helping extract shipping data from supplier emails. Here are some rules to followL\n1. If the Shipping Method shows as Counter just ignore and do not execute the workflow as we do not need to send any data when is a Counter sale. In this case just return the word COUNTER\n2. If the Shipping Method contains **\"FEDEX-GND\"**, normalize and return `\"carrier\": \"FedEx\"`. We need to standardize carriers to o FedEx and UPS only.\n\n\n\nIf Shipping Method is any other than COUNTER do the following. Extract the following information from this email and return it as JSON:\n- tracking_number: The package tracking number\n- carrier: The shipping carrier (FedEx or UPS). If the email contains FEDEX-GND then return FedEx\n- customer: The customer name\n- purchase_order: Any purchase order number mentioned\n- address: The shipping address\n\nReturn a clean JSON in this format:\n\n{\n  \"tracking_number\": \"\",\n  \"carrier\": \"\",\n  \"customer\": \"\",\n  \"purchase_order\": \"\",\n  \"street\": \"\",\n  \"city\": \"\",\n  \"state\": \"\",\n  \"zip\": \"\",\n  \"user_id\": \"user_test_123\",\n  \"contents\": [\n    {\n      \"name\": \"string\",\n      \"quantity\": number,\n      \"price\": number or null,\n      \"part number\": \"string or null\",\n      \"description\": \"string or null\",\n      \"ref\": \"string or null\"\n    }\n  ]\n}\n\nHere is the email:\n{{ $json.html}}",
        "hasOutputParser": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        352,
        224
      ],
      "id": "4b4934ec-6659-4b50-8670-117918a82a92",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1-mini",
          "mode": "list",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        288,
        448
      ],
      "id": "3d57f007-3325-49aa-8fb0-48dae73dc33a",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "9d01Yb8z3wRAj5tY",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "mode": "raw",
        "jsonOutput": "={\n  \"packages\": [\n    {\n      \"tracking_number\": \"{{ $json.output.packages[0].tracking_number }}\",\n      \"carrier\": \"{{ $json.output.packages[0].carrier }}\",\n      \"customer\": \"{{ $json.output.packages[0].customer }}\",\n      \"purchase_order\": \"{{ $json.output.packages[0].purchase_order }}\",\n      \"street\": \" {{ $json.output.packages[0].street }}\",\n \"city\": \"{{ $json.output.packages[0].city }}\",\n\"state\": \"{{ $json.output.packages[0].state }}\",\n \"zip\": \"{{ $json.output.packages[0].zip }} \",\n\"contents\": [\n        {\n          \"name\": \"{{ $json.output.packages[0].contents[0].name }} \",\n          \"quantity\": {{ $json.output.packages[0].contents[0].quantity }},\n          \"price\": {{ $json.output.packages[0].contents[0].price }},\n          \"sku\": \" {{ $json.output.packages[0].contents[0].sku }}\",\n          \"description\": \" {{ $json.output.packages[0].contents[0].description }}\",\n\"ref\": \" {{ $json.output.packages[0].contents[0].ref }}\"\n        }]\n    }\n  ]\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1296,
        240
      ],
      "id": "07c469e8-ac70-445a-a339-da12a7a81294",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "text": "={{ $json.output }}",
        "schemaType": "fromJson",
        "jsonSchemaExample": "{\n  \"packages\": [\n    {\n      \"tracking_number\": \"123456789012\",\n      \"carrier\": \"FedEx\",\n      \"customer\": \"Acme Corp\",\n      \"purchase_order\": \"PO-12345\",\n      \"street\": \"123 Main St\",\n      \"city\": \"Greenville\",\n      \"state\": \"SC\",\n      \"zip\": \"29611\",\n      \"contents\": [\n        {\n          \"name\": \"Sony WH-1000XM4 Wireless Headphones\",\n          \"quantity\": 1,\n          \"price\": 349.99,\n          \"sku\": \"WH1000XM4-B\",\n          \"description\": \"Noise-canceling over-ear headphones with 30-hour battery life\",\n          \"ref\": \"string or null\"\n        },\n        {\n          \"name\": \"Anker USB-C Cable 6ft\",\n          \"quantity\": 2,\n          \"price\": 12.99,\n          \"sku\": \"A8023011\",\n          \"description\": \"High-speed charging cable with braided design\", \"ref\": \"string or null\"\n        }\n      ]\n    }\n  ]\n}",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1.1,
      "position": [
        944,
        240
      ],
      "id": "94e7f836-6348-4f7a-9c6c-8c557ab1a3f1",
      "name": "Information Extractor"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        1024,
        464
      ],
      "id": "be5f4389-c44f-4deb-be9b-85f98c2bcb6d",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "id": "9d01Yb8z3wRAj5tY",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "a1a791cd-800f-44ef-aa38-d9702d2c446b",
              "leftValue": "={{ $json.output }}",
              "rightValue": "=COUNTER",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        672,
        224
      ],
      "id": "cd79eb8c-a4b1-4293-a269-3719b1cd77b4",
      "name": "If"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1x68l7BYIJGF5r1xHDYEuDzQo5xLOT50H3ytv_VT3_Lk",
          "mode": "list",
          "cachedResultName": "Tracking Number Updated Test",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1x68l7BYIJGF5r1xHDYEuDzQo5xLOT50H3ytv_VT3_Lk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1x68l7BYIJGF5r1xHDYEuDzQo5xLOT50H3ytv_VT3_Lk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Tracking": "={{ $json.packages[0].tracking_number }}",
            "Customer": "={{ $json.packages[0].customer }}",
            "Carrier": "={{ $json.packages[0].carrier }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Carrier",
              "displayName": "Carrier",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Tracking",
              "displayName": "Tracking",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer",
              "displayName": "Customer",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "ETA",
              "displayName": "ETA",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Actual Delivered",
              "displayName": "Actual Delivered",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Comments",
              "displayName": "Comments",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Proof fo Delivery",
              "displayName": "Proof fo Delivery",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1504,
        240
      ],
      "id": "95376e8e-9753-4b12-9e45-fc8c73300ccc",
      "name": "Append row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "e6ow0ICBmycDSAPC",
          "name": "Google Sheets Greenville"
        }
      }
    },
    {
      "parameters": {
        "content": "## Step 1\n**Configure the Gmail Trigger (Email Intake)**\n- Open the Gmail Trigger node and connect your Gmail credentials.\n- This workflow is already filtering for:\n      Subject: Marcone Instant Shipping Notification\n      Sender: no-replies@marcone.com\n\n✅ Double-check the sender address in your real emails. If Marcone uses a slightly different sender in your region, update it here.\n✅ If you need to modify for a different vendor change Subject and Sender fields\n\nRecommended:\nPolling every 5 minutes (every minute is fine, but unnecessary for most shops)\n",
        "height": 624,
        "width": 384
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -192
      ],
      "typeVersion": 1,
      "id": "1aea4ad3-0a11-4df3-ad08-ec6c8eec71ca",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Step 2\n**Connect the OpenAI Credentials (Two Nodes)**\n\nThis workflow uses OpenAI in two places:\n   - OpenAI Chat Model → used by the AI Agent\n   - OpenAI Chat Model1 → used by the Information Extractor\n Marcone Email Tracking Extractor\n\n**Do this:**\n - Open each OpenAI node\n - Click Create new credential\n - Paste your OpenAI API key\n\n✅ Leave the models as-is unless you have a reason to change them.\n\nFor assistance visit: https://docs.n8n.io/integrations/builtin/credentials/openai",
        "height": 624,
        "width": 912,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        304,
        -192
      ],
      "typeVersion": 1,
      "id": "2e467f03-5031-45cf-8e38-a0ab88de5a83",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Step 3\n**Set Your Google Sheet Destination\n** \n- Open the Append row in sheet node and connect Google Sheets credentials.\n\nThen:\n- Select your Spreadsheet\n- Select the Sheet tab (Sheet1 or your preferred tab)\n- Confirm the mapping fields match your column headers\n\n**Minimum recommended columns**\nTracking\nCustomer\nCarrier\n\n(That’s what the workflow appends today.)\n\nFor assistance visit: https://docs.n8n.io/integrations/builtin/credentials/google\n",
        "height": 624,
        "width": 480,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1408,
        -192
      ],
      "typeVersion": 1,
      "id": "ae896c94-1525-419c-83e4-4e9a4034ad0b",
      "name": "Sticky Note2"
    }
  ],
  "pinData": {},
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Information Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [],
        [
          {
            "node": "Information Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "versionId": "50bd5cd9-f7d7-4cf2-83e2-5c063b1b3ee2",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "992f6b15ce9418f680548f917c88a9daa82a875a56a26e12ae36d126941f6f18"
  },
  "id": "MwWAcpvEyjbnYGJq",
  "tags": []
}